home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / fgetc.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  918b  |  47 lines

  1. /* FGetC.c   V1.1   93-03-03                   */
  2. /* ROM library: "dos.library/FGetC", (V36+)    */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. UBYTE *version = "$VER: FGetC 1.1";
  12.  
  13. int main( int argc, char *argv[] );
  14. int main( int argc, char *argv[] )
  15. {
  16.   BPTR my_file;
  17.   LONG collected;
  18.  
  19.  
  20.   /* Open an already existing file: */ 
  21.   my_file = Open( "RAM:Important.dat", MODE_OLDFILE );
  22.   if( !my_file )
  23.     exit( 20 );
  24.  
  25.   /* Read one character: */
  26.   collected = FGetC( my_file );
  27.  
  28.   /* OK? */
  29.   if( collected == -1 )
  30.   {
  31.     /* Could not collect the character! */
  32.     /* Check if it was EOF or an Error: */
  33.     if( IoErr() )
  34.       printf( "There was an error!\n" );
  35.     else
  36.       printf( "End of file (EOF)!\n" );
  37.   }
  38.   else
  39.     printf( "The character was \"%c\"!\n", collected );
  40.  
  41.   Close( my_file );
  42.  
  43.   exit( 0 );
  44. }
  45.  
  46.  
  47.